var fetch4 = function(pageIndex){
  pageIndex = pageIndex || 1
  //frequentVisitorsTable		访客来访频繁居住
  $.ajax({
    type: 'GET',
    url: houseInfo.ajaxUrl[3].page(pageIndex,10),
    beforeSend: function (xhr) {
      xhr.setRequestHeader('Authorization', tokenPgAuth);
      xhr.setRequestHeader('Accept-Profile', 'api-ailock-analysis-v1');
      xhr.setRequestHeader('Prefer', 'count=exact');
    }
  }).done(function (response,type,request1) {
    houseInfo.total[3] = pgApiUtils.getTotal(request1); //总数
    $('.' + houseInfo.totalDomId[3] + 1).text(houseInfo.total[3])
    $('#' + houseInfo.totalDomId[3] + 2).text(houseInfo.total[3])
    var options = {
      bDestroy:true,
      searching: false,
      bPaginate: true ,//表格分页
      bSort: false,
      bLengthMenu: false,
      bInfo: false,
      pageLength:10, // 每页显示数量
      bAutoWidth: false,
      bLengthChange: false,
      bProcessing: true,
      pgAiDisplayLength:houseInfo.total[3],
      data: response,
      fnPageChange:function(settings){
        changePage(settings,'.frequentVisitorsTable',1)
      },
        columns: [
          {
            data: "simpleaddr",
            class: 'address',
            bSortable: false,
            align: 'left',
            render: function (data, type, full, meta) {
              if (!data) data = '--';
              return data
            }
          },
          {
            data: "housenumber",
            class: 'digit ta',
            bSortable: false,
            render: function (data, type, full, meta) {
              if (!data) data = '--';
              return data
            }
          },
          {
            data: "stats_per_lock_for_informal_last_7day",   //当前周期内发放总数   _这里需要计算keys共有多少
            align: 'left',
            className: 'ta',
            bSortable: false,
            render: function (data, type, full, meta) {
              if (!data) return '--';
              return (~~full.stats_per_lock_for_informal_last_7day.keys) * (~~full.stats_per_lock_for_informal_last_7day.tally_users)
            }
          },

        ],
    };
    options.fnInitComplete =  function (settings) {
      $('.popup-transparnt-bg').hide()
      var myOptions = jQuery.extend(options, {
        fnPageChange : function(settings){
          changePage(settings,'.frequentVisitorsTable',0)
        },
        fnInitComplete : function(settings){
          houseInfo.bindEvent[3]()
        }
      });
      $('#loadingBox').hide();
      houseInfo.tables[3][1] = $('.frequentVisitorsTable').eq(1).dataTable(myOptions);

    }

    houseInfo.tables[3][0] = $('.frequentVisitorsTable').eq(0).dataTable(options);

  })
}


houseInfo.bindEvent[3] = function () {
  $(".frequentVisitorsTable").each(function (index,item){
    $(item).on("click","td.address",function(){//给tr或者td添加click事件
      var trDom = $(this).parent()[0]
      var data=houseInfo.tables[3][index].api().row(trDom).data();//获取值的对象数据
      getRenterListAndHouseMaster(data)
    })
    $(item).on("click","td.ta",function(){//给tr或者td添加click事件
      var trDom = $(this).parent()[0]
      var data=houseInfo.tables[3][index].api().row(trDom).data();//获取值的对象数据
      informationOfVisitors(data)
    })
  })
}
